## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: t; coding: utf-8; -*-
# encoding: utf-8

VERSION = '0.1'
APPNAME = 'wxode'

top = '.'
out = 'build'

def configure(ctx):
    from waflib import Options
    
    if Options.options.debugmode != 'true' and Options.options.debugmode != 'false':
        waflib.Logs.warn("Warning, the --debug option may only be 'true' or 'false'. Defaulting to 'false'.")
    
    is_debug   = (Options.options.debugmode == 'true')
    
    ctx.load('compiler_c')
    ctx.load('compiler_cxx')

    ctx.find_program('gcc', var='GCC', mandatory=True)
    ctx.find_program('g++', var='GPP', mandatory=True)
    ctx.check_cc(header_name="stdio.h", function_name='printf', msg='Checking C compiler works', errmsg="No")
    ctx.check_cxx(header_name="cstdio", function_name='printf', msg='Checking C++ compiler works', errmsg="No")

    ctx.check_cfg(msg="Checking for wxWidgets 2.8.x", path='wx-config',  args='--version=2.8 --cxxflags --libs adv,aui,core,base,gl,html ', package='', uselib_store='wxWidgets')
    pass

def options(opt):
    opt.add_option('--debug', action='store', help='Whether to make a debug build (may be \'true\' or \'false\')', default='false', dest="debugmode")

    opt.load('compiler_cxx')
    opt.load('compiler_c')
    pass

def build(bld):
    link_flags = []
    build_flags = []

    if bld.env['is_debug']:
	build_flags += ['-g', '-DDEBUG=1']
    else:
	build_flags += ['-O2','-DNEBUG=1']


    bld.program(features='c cxx cxxprogram',
		cxxflags=build_flags,
		linkflags=link_flags,
		source=['src/xodeapp.cc','src/xodewin.cc'],
		target='wxode',
		uselib='wxWidgets',
		includes=['./include',])
    pass

